package com.example.demo.spring;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.inject.Inject;

/**
 * @author wangsl
 * @date 2020/7/5 22:51
 * <p>
 * Description:
 */
@Component("myUser")
//@Component(没有明确角色的时候使用)注解表示其是容器的一个组件,无法设置初始和销毁方法操作
public class User {

    @Autowired
    private UserService userService;

    @Resource//JSR-250注解
    private Car car;

    @Inject//JSR-330注解
    private Cat cat;

    @Override
    public String toString() {
        return "User{" +
                "userService=" + userService +
                ", car=" + car +
                ", cat=" + cat +
                '}';
    }

    /*public void show() {
        System.out.println("--------show--------");
        System.out.println(userService);
    }*/
}
